#!/usr/bin/env bash

# Copyright (C) 2009-2019 Lightbend Inc. <https://www.lightbend.com>

# shellcheck source=scripts/scriptLib
. "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/scriptLib"

cd "$DOCUMENTATION"

start validate-docs "RUNNING DOCUMENTATION VALIDATION"
runSbt evaluateSbtFiles
runSbt validateDocs
runSbt headerCheck test:headerCheck

scalafmtValidation "documentation"
javafmtValidation "documentation"

end validate-docs "ALL DOCUMENTATION VALIDATION PASSED"

# Check that markdown files have copyright headers

./addMarkdownCopyright

# Only checks diffs inside the documentation directory
git diff --exit-code . || (
  echo "ERROR: Documentation copyright or sources license header check failed, see differences above."
  echo "To fix, run the './addMarkdownCopyright' script inside the documentation directory or 'sbt test:compile' at the root of the repo."
  echo "After that you can update your pull request."
  false
)
